package com.cskaoyan.controller.wx.lghc;

import com.cskaoyan.module.bean.BaseRespVo;
import com.cskaoyan.module.bean.vo.VxAfterSaleVO;
import com.cskaoyan.module.pojo.MarketAftersale;
import com.cskaoyan.module.pojo.MarketOrderGoods;
import com.cskaoyan.service.wx.lghc.VxAfterSaleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.math.BigDecimal;

/**
 * @author :ligenghuisheng
 * @Description:
 * @Date :2022/4/8  16:31
 */
@RestController
@RequestMapping("wx/aftersale")
public class VxAfterSaleController {

    @Autowired
    VxAfterSaleService vxAfterSaleService;


    //小程序售后list
    @RequestMapping("list")
    public BaseRespVo listAfterSale(VxAfterSaleVO vxAfterSaleVO, MarketAftersale marketAftersale, MarketOrderGoods marketOrderGoods){



        VxAfterSaleVO vxAftersaleVO = vxAfterSaleService.listAfterSale(vxAfterSaleVO,marketAftersale,marketOrderGoods);


        return BaseRespVo.ok(vxAftersaleVO);
    }


    ///wx/aftersale/detail?orderId=214
    @RequestMapping("detail")
    public BaseRespVo detail(Integer orderId){
        return BaseRespVo.ok(vxAfterSaleService.selectAftersaleOrOrder(orderId));
    }

    //http://182.92.235.201:8083/wx/aftersale/submit
    @PostMapping("submit")
    public BaseRespVo submit(@RequestBody Integer orderId, BigDecimal amount, String[] pictures, String reason, Short type, String typeDesc){

        int code = vxAfterSaleService.updateAftersale(orderId,amount,pictures,reason,type,typeDesc);
        if (code == 1){
            return BaseRespVo.ok("成功");
        }else {
            return BaseRespVo.invalidData();
        }
    }
}
